package com.you.common.result;

/**
 * @author yunpeng.jiangyp
 * @param <T>
 */
public class ServiceResult<T> {

    private T       failureReason;
    private boolean success;
    private Object  module;

    public ServiceResult(boolean success, T failureReason){
        this.success = success;
        this.failureReason = failureReason;
    }
    
    public Object getModule() {
        return module;
    }

    public ServiceResult<T> setModule(Object module) {
        this.module = module;
        return this;
    }

    public T getFailureReason() {
        return failureReason;
    }

    public void setFailureReason(T failureReason) {
        this.failureReason = failureReason;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public static <T> ServiceResult<T> newSuccessResult() {
        return new ServiceResult<T>(true, null);
    }

    public static <T> ServiceResult<T> newFailureResult(T failureReason) {
        return new ServiceResult<T>(false, failureReason);
    }

}
